﻿open System

open System.IO

let root = @"C:\Users\yin\Desktop\acmcode\acmcode"

let folders = Directory.GetDirectories(root)

let getLast (path:string) = 
    let s = path.Split('\\')
    s.[s.Length-1]

let getLast2 (path:string) = 
    let s = path.Split('\\')
    s.[s.Length-2]


let allFiles = 
    folders
    |> Array.map (fun folder -> 
        Directory.GetFiles(folder))
    |> Array.concat
    |> Array.map (fun file -> 
        getLast2 file, getLast file)


allFiles
|> Array.map (fun (folder, name) ->
    let s = sprintf "<li><a href=\"http://www.cse.ust.hk/~yinz/acmcode/%s/%s\">%s</a> :\n d <p></p></li>" folder name (folder+"-"+name)
    printfn "%s" s
    s )
|> ignore
    